home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / OpenDoc Development / Debugging Support / OpenDoc Source Code / Utilities / Interfaces / TempObj.th < prev    next >
Encoding:
Text File  |  1996-04-22  |  1.6 KB  |  78 lines  |  [TEXT/MPS ]

  1. /*
  2. #    File:        TempObj.th
  3. #
  4. #    Contains:    Internal header for use by TempObj.h
  5. #
  6. #    Owned by:    Jens Alfke
  7. #
  8. #    Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  9. #
  10. #        
  11. */
  12.  
  13. // This header is a utility used by TempObj.h. Do not include it directly unless you
  14. // really know what you're doing -- see the Tech Note "Temporary Objects/References".
  15.  
  16. #ifndef SOM_ODStorageUnitView_xh
  17. #include <SUView.xh>
  18. #endif
  19.  
  20. #ifndef SOM_ODTypeList_xh
  21. #include <TypeList.xh>
  22. #endif
  23.  
  24. #ifndef _T_
  25. #error _T_ must be defined before including a .th file
  26. #endif
  27. #ifndef _C_
  28. #error _C_ must be defined before including a .th file
  29. #endif
  30.  
  31. //===========================================================================
  32. //    TempObj <T>
  33. //===========================================================================
  34.  
  35. #ifdef __SC__
  36. // Some of the typecasts below offend certain compilers.
  37. #pragma options(!warn_cast_incomplete_type)
  38. #endif
  39.  
  40. #ifdef _TMPL_IMPL_
  41.  
  42.     // Implementation of the TempObj constructor:
  43.     _C_::_C_( _T_ *obj )
  44.     {
  45.         fObj = (ODObject*) obj;
  46.     }
  47.     
  48.     _C_::~_C_( )
  49.     {
  50.         // Prevent compiler from inlining synthesized destructor
  51.         // which causes code bloat.
  52.     }
  53.  
  54. #else
  55.  
  56.     // Declaration of the TempObj class
  57.     class _C_ :public BaseTempObj
  58.     {
  59.         public:
  60.         _C_( _T_* );
  61.         virtual ~_C_( );
  62.         _T_* operator-> ()            {return (_T_*)fObj;}
  63.         operator _T_* ()            {return (_T_*)fObj;}
  64.     
  65.         _T_* operator= (_T_* t)        {fObj=(ODObject*)t; return t;}
  66.         
  67.         _T_* DontDelete()            {_T_* temp=(_T_*)fObj; fObj=kODNULL; return temp;}
  68.     };
  69.  
  70. #endif
  71.  
  72. #ifdef __SC__
  73. #pragma options(warn_cast_incomplete_type)
  74. #endif
  75.  
  76. #undef _T_
  77. #undef _C_
  78.